<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>冒泡排序</title>
</head>
<body>
12
<script>
    // 冒泡算法
    let num = [5,4,3,2,1]
    for (let i = 0;i<num.length-1;i++){
        for (let j=0;j<num.length-i-1;j++){
            if(num[j]>num[j+1]){
                let temp = num[j]
                num[j]=num[j+1]
                num[j+1] = temp
            }
        }
    }
    console.log(num)
</script>
</body>
</html>